package ai.cast.reconnaissance.mcp_tool;

import org.springframework.ai.tool.ToolCallback;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.ai.tool.function.FunctionToolCallback;
import org.springframework.ai.tool.method.MethodToolCallbackProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ToolConfiguration {

    @Bean
    public ToolCallbackProvider timeTools(TimeTool timeTool) {
        return MethodToolCallbackProvider.builder().toolObjects(timeTool).build();
    }

    @Bean
    public ToolCallbackProvider weatherTools(EnvironmentTool environmentTool) {
        return MethodToolCallbackProvider.builder().toolObjects(environmentTool).build();
    }

    /**
     * 将输入字母转为大写的 MCP Tools
     */
    @Bean
    public ToolCallback toUpperCaseTool() {
        return FunctionToolCallback.builder("toUpperCase", (TextInput input) -> input.input().toUpperCase())
            .inputType(TextInput.class)
            .description("Put the text to upper case")
            .build();
    }

    public record TextInput(String input) {
    }
}
